/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
package com.airlogger.utils
{
	import com.bourre.log.LogLevel;
	
	public class LogLevelUtils
	{
		public static function getLevelFromNumber ( level : uint ) : LogLevel
		{
			var lev : LogLevel;
			
			switch ( level )
			{
				case uint.MIN_VALUE : lev = LogLevel.ALL; break;
				case uint.MAX_VALUE : lev = LogLevel.OFF; break;
				case 10000 : lev = LogLevel.DEBUG; break;
				case 20000 : lev = LogLevel.INFO; break;
				case 30000 : lev = LogLevel.WARN; break;
				case 40000 : lev = LogLevel.ERROR; break;
				case 50000 : lev = LogLevel.FATAL; break;
			}
			
			return lev;
		}
		
		public static function getLevelFromName ( level : String ) : LogLevel
		{
			var lev : LogLevel;
			
			switch ( level )
			{
				case "OFF" : lev = LogLevel.OFF; break;
				case "DEBUG" : lev = LogLevel.DEBUG; break;
				case "INFO" : lev = LogLevel.INFO; break;
				case "WARN" : lev = LogLevel.WARN; break;
				case "ERROR" : lev = LogLevel.ERROR; break;
				case "FATAL" : lev = LogLevel.FATAL; break;
				case "ALL" : lev = LogLevel.ALL; break;
			}
			
			return lev;
		}
	}
}